package com.shwread.android.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;

import com.shwread.android.qysw10000243.R;


/**
 * 移除群成员dialog
 * @author 刘宾  
 * @date 2015年5月29日 上午10:20:44
 */
public class RemoveTeamMemberDialog
        extends
        Dialog
        implements
        android.view.View.OnClickListener
{
	private int            gravity;
	private Context        context;
	private Button         removeBtn;
	private Button         cancelBtn;
	private RemoveListener listener;
	
	/**
	 * 创建自定义dialog
	 * 
	 * @param context
	 */
	public RemoveTeamMemberDialog(Context context) {
		this(context, Gravity.BOTTOM);
	}
	
	/**
	 * 创建自定义dialog
	 * 
	 * @param context
	 * @param gravity
	 *            布局文件的对齐方式
	 */
	public RemoveTeamMemberDialog(Context context, int gravity) {
		super(context, R.style.common_dialog);
		this.context = context;
		this.gravity = gravity;
	}
	
	public void setListener(RemoveListener listener) {
		this.listener = listener;
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View view = LayoutInflater.from(context).inflate(R.layout.remove_team_member_dialog, null);
		removeBtn = (Button) view.findViewById(R.id.remove_member_btn);
		cancelBtn = (Button) view.findViewById(R.id.remove_member_cancel_btn);
		removeBtn.setOnClickListener(this);
		cancelBtn.setOnClickListener(this);
		
		setContentView(view);
		getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
		getWindow().setGravity(gravity);
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.remove_member_btn:
				if(null != listener) listener.onRemove();
				this.dismiss();
				break;
			case R.id.remove_member_cancel_btn:
				this.dismiss();
				break;
		}
	}
	
	public interface RemoveListener{
		void onRemove();
	}
}
